<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active{
      color: red;
    }
    .background{
      background-color: pink;
    }
    .btn{
      padding: 10px;
      border-radius: 8px;
      color: white;
      border: none;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 
      对象形式绑定class 
    -->
    <div :class="box" ></div>

    <button 
    v-for="i in 5" 
    v-bind:class="{active:i===page}"
    @click="goPage(i)"
    >{{i}}</button>
    <!-- 
      数组形式绑定class
    -->
    <button :class="['active','background','btn']">按钮</button>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    const app=new Vue({
      el:"#app",
      data:function(){
        return {
          box:{
            red:'red',
            box:'box',
            container:'container'
          },
          // 选中页
          page:3
        }
      },
      methods:{
        goPage(p){
          // 点击页码后改变选中页
          this.page = p
        }
      }
    })
  </script>
</body>
</html>